Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to obtain the value of a custom contributor field via a RTC participant plugin?

Hello,

I have a work item with a custom field (of type Contributor) called:

   Requested By:

If for example, this field is set to "John Smith", how can I get the name of the user which is set in the work item via a RTC participant plugin?

/**
 * Gets the value of a Work Item (Contributor (User)) attribute.
 */
public String getAttributeValue_Contributor(String attributeID) throws TeamRepositoryException
{
   String returnValue = "";
   IAttribute attribute = workItemServer.findAttribute(workItem.getProjectArea(), attributeID, monitor);
  
   Object value = workItem.getValue(attribute);
      
   // ???
   returnValue = contributor.getName();
   return returnValue;
}

Thanks!

 

0 votes


Accepted answer

Permanent link
Thanks Ralph.

I have it working now :-)


import com.ibm.team.repository.common.IContributor;
import com.ibm.team.repository.common.IContributorHandle;
import com.ibm.team.repository.service.IRepositoryItemService;
-----------------------------------------------------------
IRepositoryItemService itemService = getService(IRepositoryItemService.class);
-----------------------------------------------------------   
  /**
   * Gets the value of a Work Item (Contributor (User)) attribute.
*
*/
public String getAttributeValue_Contributor(String attributeID) throws TeamRepositoryException {
String returnValue = "";

IAttribute attribute = workItemServer.findAttribute(workItem.getProjectArea(), attributeID, monitor);

IContributorHandle contributorHandle = (IContributorHandle) workItem.getValue(attribute); IContributor contributor = (IContributor) itemService.fetchItem(contributorHandle, null);

      returnValue = contributor.getName();
      return returnValue;    }

Ralph Schoon selected this answer as the correct answer

0 votes


One other answer

Permanent link
Do a getValue()
Test if the instance of the object is an IContributorHandle, cast to the IContributorHandle, resolve the contributor from the handle. See https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/

This is true for almost all the values. You have to always cast the data and it is easy enough to look at what it is in a debugging session. Also see https://rsjazz.wordpress.com/2013/03/20/understanding-and-using-the-rtc-java-client-api/

1 vote

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jul 14 '15, 5:48 a.m.

Question was seen: 3,587 times

Last updated: Jul 14 '15, 8:06 a.m.

Confirmation Cancel Confirm